<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2019/5/20
 * Time: 11:14
 */

namespace app\index\controller;
use app\admin\model\User;
use app\admin\model\WechatConfig;
use think\facade\Session;

class Personal extends Base
{
    public function personal(){
        $user=User::where('id',Session::get('user_id'))->find();
        $this->assign('user',$user);

        $wechat=WechatConfig::where('wx_id',1)->find();
        $this->assign('wechat',$wechat);

        $this->assign('pageType','personal');
        return $this->fetch();
    }
    public function userSetup(){
        if(request()->post()){
            $post=input('post.');
            $data=[
                'true_name'=>$post['true_name'],
                'phone'=>$post['phone']
            ];
            $save=User::where('id',Session::get('user_id'))->update($data);
            if($save){
                return json(['code'=>1,'msg'=>'保存成功!']);
            }
            return json(['code'=>0,'msg'=>'保存失败!']);
        }
        return $this->fetch();
    }
    public function userData(){
        $data=User::where('id',Session::get('user_id'))->find();
        return json(['code'=>1,'msg'=>'返回成功！','data'=>$data]);
    }




}